<ul class="nav nav-tabs">
	<li><a href="javascript:;" ng-click="access('list')">返回列表</a></li>
</ul>
<div class="panel panel-default form-horizontal">
	<div class="panel-heading">设置数据表结构</div>
	<div class="panel-body">
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label">数据表标识</label>
			<div class="col-xs-12 col-sm-8 col-lg-9">
				<input type="text" class="form-control " ng-model="pagedata.item.name" ng-readonly="pagedata.read" />
				<div class="help-block">数据表标识将用于生成数据表名。数据表名为：表前缀+插件标识+表标识</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label">数据表名称</label>
			<div class="col-xs-12 col-sm-8 col-lg-9">
				<input type="text" class="form-control " ng-model="pagedata.item.title" />
				<div class="help-block">取个名字便于识别</div>
			</div>
		</div>
		<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 left-label">数据表类型</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<div class="radio radio-inline" ng-repeat="(value,dtitle) in pagedata.types">
						<label>
							<input type="radio" value="{{value}}" ng-model="pagedata.item.type"/>{{dtitle}}
						</label>
					</div>
					<div class="help-block"></div>
				</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label">关联表</label>
			<div class="col-xs-12 col-sm-8 col-lg-9">
				<select class="form-control" ng-model="pagedata.item.fid">
					<option value="0" selected>请选择</option>
					<option ng-repeat="op in pagedata.fathers" ng-selected="pagedata.item.fid==op.id" value="{{op.id}}" >{{op.title}}</option>
				</select>
				<div class="help-block">如果数据表类型为主表，此处选择数据表的父表（如无父级表可不设置）；如果数据表类型为附表，此处选择数据表的主表（附表必须设置所属主表）</div>
			</div>
		</div>
	<div class="form-group-title">
		字段管理（温馨提示，系统会默认加上uniacid字段用于保存站点ID，加上createtime字段用于保存创建时间，因此这两个字段无需重复添加）
	</div>
	<div class="table-responsive" class="panel-body" ng-init="checkarray(pagedata.item,'fields')">
			<table class="table jinyun-table table-hover vertical-middle jinyun-form">
				<thead>
					<tr>
						<th>字段标识</th>
						<th>字段名称</th>
						<th>字段类型</th>
						<th class="text-right" style="word-break : break-all;">操作</th>
					</tr>
				</thead>
				<tbody id="re-items">
					<tr ng-repeat="item in pagedata.item.fields">
						<td><input type="text" ng-model="item.name"/></td>
						<td><input type="text" ng-model="item.title"/></td>
						<td>
							<select ng-model="item.leixing">
								<option ng-repeat="vt in pagedata.leixing" value="{{vt.id}}" ng-selected="item.leixing==vt.id">{{vt.title}}</option>
							</select>
						</td>
						<td class="text-right">
							<a href="javascript:;" ng-click="pagedata.item.fields.splice($index,1)" title="删除此条目" class="btn btn-primary btn-sm"><i class="fa fa-times"></i></a> &nbsp;
							<a href="javascript:;" title="详情" ng-click="pagedata.edit(item)" class="btn btn-primary btn-sm"><i class="fa fa-edit"></i></a>
						</td>
					</tr>
					<tr>
						<td colspan='4' class="text-left">
							<a class="color-gray add-new-keyword" href="javascript:;" ng-click="newfield={};pagedata.item.fields.push(newfield);">
								<span class="add-icon"><i class="fa fa-plus"></i></span>
								<span class="text">添加一个字段</span>
							</a>
						</td>
					</tr>
				</tbody>
			</table>
	</div>
	<div class="modal-sub"><button  class="btn btn-primary" ng-click="post(pagedata.item,'post')">提交</button></div>
	</div>
</div>
<div id="floating-content-detail" ng-init="pagedata.current_field={}" class="modal fade" data-cs="xxx" tabindex="-1" style="z-index:1039;display:none">
    <div class="jinyun-modal-dialog modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>设置详细信息</h3></div>
			<div class="modal-body form-horizontal">
			<div class="form-group" >
				<label class="col-xs-12 col-sm-3 col-md-2 left-label">设置选项信息</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<textarea style="height:200px;" class="form-control " ng-model="pagedata.current_field.content" cols="70"></textarea>
					<div class="help-block">如果数据类型为单选、多选、状态码类型。请在此设置选项信息，格式为一行一个选项，选项值和选项名称以英文逗号隔开。如果需要从数据库读取数据作为选项。则按以下格式（table,数据表名,标题字段,筛选字段,字段值来源）其中字段值来源有两种，1表示来自环境参数，2表示来自请求参数；筛选字段和字段值来源两项可不设置</div>
				</div>
			</div>
			</div>
            <div class="modal-footer"><a href="#" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">完成</a></div>
        </div>
    </div>
</div>
<script>
window.scope.pagedata.edit=function(item){
	window.scope.pagedata.current_field=item;
	window.bootstrap('#floating-content-detail').modal();
}
</script>